home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / ndbm.man < prev    next >
Encoding:
Text File  |  1989-01-16  |  5.9 KB  |  199 lines

  1.  
  2.  
  3.  
  4. NDBM                  C Library Procedures                   NDBM
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      dbm_open, dbm_close, dbm_fetch, dbm_store, dbm_delete,
  10.      dbm_firstkey, dbm_nextkey, dbm_error, dbm_clearerr - data
  11.      base subroutines
  12.  
  13. SSYYNNOOPPSSIISS
  14.      ##iinncclluuddee <<nnddbbmm..hh>>
  15.  
  16.      ttyyppeeddeeff ssttrruucctt {{
  17.          cchhaarr **ddppttrr;;
  18.          iinntt ddssiizzee;;
  19.      }} ddaattuumm;;
  20.  
  21.      DDBBMM **ddbbmm__ooppeenn((ffiillee,, ffllaaggss,, mmooddee))
  22.          cchhaarr **ffiillee;;
  23.          iinntt ffllaaggss,, mmooddee;;
  24.  
  25.      vvooiidd ddbbmm__cclloossee((ddbb))
  26.          DDBBMM **ddbb;;
  27.  
  28.      ddaattuumm ddbbmm__ffeettcchh((ddbb,, kkeeyy))
  29.          DDBBMM **ddbb;;
  30.          ddaattuumm kkeeyy;;
  31.  
  32.      iinntt ddbbmm__ssttoorree((ddbb,, kkeeyy,, ccoonntteenntt,, ffllaaggss))
  33.          DDBBMM **ddbb;;
  34.          ddaattuumm kkeeyy,, ccoonntteenntt;;
  35.          iinntt ffllaaggss;;
  36.  
  37.      iinntt ddbbmm__ddeelleettee((ddbb,, kkeeyy))
  38.          DDBBMM **ddbb;;
  39.          ddaattuumm kkeeyy;;
  40.  
  41.      ddaattuumm ddbbmm__ffiirrssttkkeeyy((ddbb))
  42.          DDBBMM **ddbb;;
  43.  
  44.      ddaattuumm ddbbmm__nneexxttkkeeyy((ddbb))
  45.          DDBBMM **ddbb;;
  46.  
  47.      iinntt ddbbmm__eerrrroorr((ddbb))
  48.          DDBBMM **ddbb;;
  49.  
  50.      iinntt ddbbmm__cclleeaarreerrrr((ddbb))
  51.          DDBBMM **ddbb;;
  52.  
  53. DDEESSCCRRIIPPTTIIOONN
  54.      These functions maintain key/content pairs in a data base.
  55.      The functions will handle very large (a billion blocks)
  56.      databases and will access a keyed item in one or two file
  57.      system accesses.  This package replaces the earlier _d_b_m(3x)
  58.      library, which managed only a single database.
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0             December 5, 1987                        1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. NDBM                  C Library Procedures                   NDBM
  71.  
  72.  
  73.  
  74.      _K_e_ys and _c_o_n_t_e_n_ts are described by the _d_a_t_u_m typedef.  A
  75.      _d_a_t_u_m specifies a string of _d_s_i_z_e bytes pointed to by _d_p_t_r.
  76.      Arbitrary binary data, as well as normal ASCII strings, are
  77.      allowed.  The data base is stored in two files.  One file is
  78.      a directory containing a bit map and has `.dir' as its suf-
  79.      fix.  The second file contains all data and has `.pag' as
  80.      its suffix.
  81.  
  82.      Before a database can be accessed, it must be opened by
  83.      _d_b_m__o_p_e_n.  This will open and/or create the files _f_i_l_e..ddiirr
  84.      and _f_i_l_e..ppaagg depending on the flags parameter (see _o_p_e_n(2)).
  85.  
  86.      Once open, the data stored under a key is accessed by
  87.      _d_b_m__f_e_t_c_h and data is placed under a key by _d_b_m__s_t_o_r_e.  The
  88.      _f_l_a_g_s field can be either DDBBMM__IINNSSEERRTT or DDBBMM__RREEPPLLAACCEE..
  89.      DDBBMM__IINNSSEERRTT will only insert new entries into the database
  90.      and will not change an existing entry with the same key.
  91.      DDBBMM__RREEPPLLAACCEE will replace an existing entry if it has the
  92.      same key.  A key (and its associated contents) is deleted by
  93.      _d_b_m__d_e_l_e_t_e.  A linear pass through all keys in a database
  94.      may be made, in an (apparently) random order, by use of
  95.      _d_b_m__f_i_r_s_t_k_e_y and _d_b_m__n_e_x_t_k_e_y.  _D_b_m__f_i_r_s_t_k_e_y will return the
  96.      first key in the database.  _D_b_m__n_e_x_t_k_e_y will return the next
  97.      key in the database.  This code will traverse the data base:
  98.  
  99.           ffoorr (key = dbm_firstkey(db); key.dptr != NULL; key =
  100.           dbm_nextkey(db))
  101.  
  102.      _D_b_m__e_r_r_o_r returns non-zero when an error has occurred read-
  103.      ing or writing the database.  _D_b_m__c_l_e_a_r_e_r_r resets the error
  104.      condition on the named database.
  105.  
  106. DDIIAAGGNNOOSSTTIICCSS
  107.      All functions that return an _i_n_t indicate errors with nega-
  108.      tive values.  A zero return indicates ok.  Routines that
  109.      return a _d_a_t_u_m indicate errors with a null (0) _d_p_t_r. If
  110.      _d_b_m__s_t_o_r_e called with a _f_l_a_g_s value of DDBBMM__IINNSSEERRTT finds an
  111.      existing entry with the same key it returns 1.
  112.  
  113. BBUUGGSS
  114.      The `.pag' file will contain holes so that its apparent size
  115.      is about four times its actual content.  Older UNIX systems
  116.      may create real file blocks for these holes when touched.
  117.      These files cannot be copied by normal means (cp, cat, tp,
  118.      tar, ar) without filling in the holes.
  119.  
  120.      _D_p_t_r pointers returned by these subroutines point into
  121.      static storage that is changed by subsequent calls.  This
  122.      storage is not necessarily aligned; stored ``longs'', for
  123.      example, should be copied to a properly aligned block of
  124.      memory before being accessed.
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0             December 5, 1987                        2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. NDBM                  C Library Procedures                   NDBM
  137.  
  138.  
  139.  
  140.      The sum of the sizes of a key/content pair must not exceed
  141.      the internal block size (currently 4096 bytes).  Moreover
  142.      all key/content pairs that hash together must fit on a sin-
  143.      gle block.  _D_b_m__s_t_o_r_e will return an error in the event that
  144.      a disk block fills with inseparable data.
  145.  
  146.      _D_b_m__d_e_l_e_t_e does not physically reclaim file space, although
  147.      it does make it available for reuse.
  148.  
  149.      The order of keys presented by _d_b_m__f_i_r_s_t_k_e_y and _d_b_m__n_e_x_t_k_e_y
  150.      depends on a hashing function, not on anything interesting.
  151.  
  152. SSEEEE AALLSSOO
  153.      dbm(3X)
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0             December 5, 1987                        3
  196.  
  197.  
  198.  
  199.